*********************************************************************
* Long-term Change in Conflict Attitudes: A Dynamic Perspective     *
* Alon Yakter and Liran Harsgor 									*
* British Journal of Political Science (2022)						*
*                                                                   *
* Replication code - ECM models                    					* *********************************************************************
* The analysis was performed with Stata 17. For model presentation, *
* users should install the estout package							* 
* (command line: "ssc install estout, replace").					*
*																	*
* to load the data (the "use" command), users should place the .dta	*
* file in their Stata working directory (or type the full file 		*
* paths as saved on their computer).                      			*
*********************************************************************

* open data
use "Yakter & Harsgor BJPS - data.dta", replace

** set data as time series
tsset ts_date, monthly

** ECM models (Table 1)
eststo clear
qui eststo: reg d.support_int_jw100 l.support_int_jw100 ld.support_int_jw100 ///
	l.log_rockets d.log_rockets l.log_casualties d.log_casualties l(1/2).negotiations d(2).negotiations l(1/2).hawkish_selection d(2).hawkish_selection ///
	d.right_cab100 l.avewage d.avewage ts_date
qui eststo: reg d.hope_int_jw100 l.hope_int_jw100 ld.hope_int_jw100 ///
	l.log_rockets d.log_rockets l.log_casualties d.log_casualties l(1/2).negotiations d(2).negotiations l(1/2).hawkish_selection d(2).hawkish_selection ///
	d.right_cab100 l.avewage d.avewage ts_date
esttab, ///
	b(3) se(3) r2(3) aic(3) bic(3) ///
	star(+ 0.1 * 0.05 ** 0.01 *** 0.001) ///
	order(L.support_int_jw100 LD.support_int_jw100 L.hope_int_jw100 LD.hope_int_jw100 ///
		D.log_rockets L.log_rockets D.log_casualties L.log_casualties D2.negotiations L.negotiations L2.negotiations ///
		D2.hawkish_selection L.hawkish_selection L2.hawkish_selection D.right_cab100 L.avewage D.avewage ts_date _cons) ///
	coeflabels(L.support_int_jw100 NetSupport.L LD.support_int_jw100 D.NetSupport.L ///
		L.hope_int_jw100 NetHope.L LD.hope_int_jw100 D.NetHope.L ///
		L.log_rockets LogRockets.L D.log_rockets D.LogRockets ///
		L.log_casualties LogCasualties.L D.log_casualties D.LogCasualties ///
		L.negotiations Negotiations.L L2.negotiations Negotiations.L2 D2.negotiations D2.Negotiations ///
		L.hawkish_selection HawkishLeadership.L L2.hawkish_selection HawkishLeadership.L2 D2.hawkish_selection D2.HawkishLeadership ///
		D.right_cab100 D.RightCabinet L.avewage AverageWage.L D.avewage D.AverageWage ts_date Trend ///
		_cons Constant) ///
	mgroups("Net Support for Negotiations" "Net Hope for Peace in Practice", pattern(1 1)) ///
	nogaps wide compress nomtitles
* breusch-godfrey LM tests
qui reg d.support_int_jw100 l.support_int_jw100 ld.support_int_jw100 ///
	l.log_rockets d.log_rockets l.log_casualties d.log_casualties l(1/2).negotiations d(2).negotiations l(1/2).hawkish_selection d(2).hawkish_selection ///
	d.right_cab100 l.avewage d.avewage ts_date
estat bgodfrey
qui reg d.hope_int_jw100 l.hope_int_jw100 ld.hope_int_jw100 ///
	l.log_rockets d.log_rockets l.log_casualties d.log_casualties l(1/2).negotiations d(2).negotiations l(1/2).hawkish_selection d(2).hawkish_selection ///
	d.right_cab100 l.avewage d.avewage ts_date
estat bgodfrey
* LRM (long-run multipliers)
	* net support
	qui reg d.support_int_jw100 l.support_int_jw100 ld.support_int_jw100 ///
		l.log_rockets d.log_rockets l.log_casualties d.log_casualties l(1/2).negotiations d(2).negotiations l(1/2).hawkish_selection d(2).hawkish_selection ///
		d.right_cab100 l.avewage d.avewage ts_date
	estat ic
	foreach v of varlist log_rockets log_casualties {
		nlcom -(_b[L.`v'])/(_b[L.support_int_jw100])
		}
	nlcom -(_b[L.negotiations]+_b[L2.negotiations])/(_b[L.support_int_jw100])
	nlcom -(_b[L.hawkish_selection]+_b[L2.hawkish_selection])/(_b[L.support_int_jw100])
	* net hope
	qui reg d.hope_int_jw100 l.hope_int_jw100 ld.hope_int_jw100 ///
		l.log_rockets d.log_rockets l.log_casualties d.log_casualties l(1/2).negotiations d(2).negotiations l(1/2).hawkish_selection d(2).hawkish_selection ///
		d.right_cab100 l.avewage d.avewage ts_date
	estat ic
	foreach v of varlist log_rockets log_casualties  {
		nlcom -(_b[L.`v'])/(_b[L.hope_int_jw100])
		}
	nlcom -(_b[L.negotiations]+_b[L2.negotiations])/(_b[L.hope_int_jw100])
	* LRR significance according to Webb et al's bounds test
	nlcom -(_b[L.hawkish_selection]+_b[L2.hawkish_selection])/(_b[L.hope_int_jw100])